#!/bin/bash
echo '>>> mvn clean package '
mvn clean package

echo '>>> stop container boot'
if sudo docker ps -a|grep -i boot;then
   sudo docker stop boot
fi

echo '>>> backup start'
basePath=/opt/boot
datename=$basePath/back/$(date +%Y%m%d-%H%M) 
sudo mkdir $datename
sudo mv $basePath/mybatisplus-spring-boot-1.0.jar $datename/
echo '>>> backup over'

echo '>>> stop container boot'
if  sudo docker ps -a|grep -i jenkins;then
    echo '>>> stop container boot'
fi

echo '>>> cp jar to prod'
sudo cp target/mybatisplus-spring-boot-1.0.jar $basePath/

echo '>>> start container boot'
sudo docker start boot
echo '>>> over'